<template>
  <li @mouseenter="showActionButtons=true" @mouseleave="showActionButtons=false">
    <p>
      <span>{{ chapter.title }}</span>
      <span class="acts" v-show="showActionButtons">
        <el-button type="text" @click="editChapterHandler(chapter)">编辑</el-button>
        <el-button type="text" @click="deleteChapterHandler(chapter.id)">删除</el-button>
        <el-button type="text" @click="addVideoHandler(chapter.id)">添加小节</el-button>
      </span>
    </p>

    <VideoList :video-list="chapter.children"/>
  </li>
</template>

<script>
import VideoList from "@/components/edu/VideoList";
export default {
  name: "ChapterListItem",
  components: {VideoList},
  data() {
    return {
      showActionButtons: false
    }
  },
  props: {
    courseId: String,
    chapter: Object,
  }
}
</script>

<style scoped>
.chapterList {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}
.chapterList li {
  position: relative;
}
.chapterList p {
  float: left;
  font-size: 20px;
  margin: 10px 0;
  padding: 10px;
  height: 70px;
  line-height: 50px;
  width: 100%;
  border: 1px solid #ddd;
}
.chapterList .acts {
  float: right;
  font-size: 14px;
}

.videoList {
  padding-left: 50px;
}
.videoList p {
  float: left;
  font-size: 14px;
  margin: 10px 0;
  padding: 10px;
  height: 50px;
  line-height: 30px;
  width: 100%;
  border: 1px dotted #ddd;
}
</style>
